package com.ruoyi.project.system.courseClass.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.system.courseClass.domain.CourseClass;
import com.ruoyi.project.system.courseClass.mapper.CourseClassMapper;
import com.ruoyi.project.system.courseClass.service.ICourseClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 课程-班级关联Service业务层处理
 *
 * @author ruoyi
 * @date 2021-04-14
 */
@Service
public class CourseClassServiceImpl implements ICourseClassService
{
    @Autowired
    private CourseClassMapper courseClassMapper;

    /**
     * 查询课程-班级关联
     *
     * @param id 课程-班级关联ID
     * @return 课程-班级关联
     */
    @Override
    public CourseClass selectCourseClassById(Long id)
    {
        return courseClassMapper.selectCourseClassById(id);
    }

    /**
     * 查询课程-班级关联列表
     *
     * @param courseClass 课程-班级关联
     * @return 课程-班级关联
     */
    @Override
    public List<CourseClass> selectCourseClassList(CourseClass courseClass)
    {
        return courseClassMapper.selectCourseClassList(courseClass);
    }

    /**
     * 新增课程-班级关联
     *
     * @param courseClass 课程-班级关联
     * @return 结果
     */
    @Override
    public int insertCourseClass(CourseClass courseClass)
    {
        courseClass.setCreateTime(DateUtils.getNowDate());
        return courseClassMapper.insertCourseClass(courseClass);
    }

    /**
     * 修改课程-班级关联
     *
     * @param courseClass 课程-班级关联
     * @return 结果
     */
    @Override
    public int updateCourseClass(CourseClass courseClass)
    {
        courseClass.setUpdateTime(DateUtils.getNowDate());
        return courseClassMapper.updateCourseClass(courseClass);
    }

    /**
     * 删除课程-班级关联对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCourseClassByIds(String ids)
    {
        return courseClassMapper.deleteCourseClassByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除课程-班级关联信息
     *
     * @param id 课程-班级关联ID
     * @return 结果
     */
    @Override
    public int deleteCourseClassById(Long id)
    {
        return courseClassMapper.deleteCourseClassById(id);
    }

    @Override
    public int deleteByCourseId(Long courseId) {
        return courseClassMapper.deleteByCourseId(courseId);
    }
}
